<?php
namespace app\model;
use app\BaseModel;
use think\model\concern\SoftDelete;

class DeviceSigning extends BaseModel
{

    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $defaultSoftDelete = '0000-00-00 00:00:00';
    protected $hidden = ['update_time','delete_time','sort','status'];

    public function searchTitleAttr($query, $value, $data)
    {
        if (!empty($value)) {

            $query->where('id_no|name_no', 'like', '%'.$value.'%');
        }
    }

    public function searchStartTimeAttr($query,$value, $data)
    {

        if (!empty($value)) {

            $query->where('create_time', '>=', $value);
        }
    }

    public function searchEndTimeAttr($query, $value, $data)
    {
        if (!empty($value)) {
            $query->where('create_time', '<=', date('Y-m-d H:i:s',strtotime($value)+3600*24));
        }
    }

    protected function setProjectIdAttr($value,$data){ //当前字段的修改器
        $this->set('project_title',Project::where('id',$value)->value('title'));
        return $value;
    }

    protected function setCompanyIdAttr($value,$data){ //当前字段的修改器
        $this->set('company_title',LeasingCompany::where('id',$value)->value('title'));
        return $value;
    }




}